package com.sakura.test;

import com.sakura.aop.MathCalculator;
import com.sakura.config.MainConfigOfAop;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author Sakura
 * @Date 2023-03-07 16:29
 */
public class IOCTest_AOP {

    @Test
    public void testAop(){
        AnnotationConfigApplicationContext configApplicationContext
                =new AnnotationConfigApplicationContext(MainConfigOfAop.class);

        //不要自己创建对象
//		MathCalculator mathCalculator = new MathCalculator();
//		mathCalculator.div(1, 1);
        MathCalculator mathCalculator = configApplicationContext.getBean(MathCalculator.class);
        mathCalculator.div(1,0);
    }
}
